/*
 * @Author: your name
 * @Date: 2021-05-21 17:25:21
 * @LastEditTime: 2021-05-22 14:04:25
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \three_demo\src\pages\3dScreen\components\right\devStatics.js
 */
import React,{useEffect} from 'react'
import axios from 'requset/request';

export default function DevStatics() {
    let  myChart ='';

    useEffect(()=>{
        myChart = window.echarts.init(document.getElementById('main'));
        axios({
            method: 'get',
            url: './json/devStatics.json',
        }).then(res=>{
            initHistoryProp(res.data);
        }).catch((err)=>{
            // message.error('操作失败');
        });
    })

    const initHistoryProp=(data)=>{
        let option = {
            tooltip: {
                 trigger: 'axis'
            },
            grid: {
                left: '5%',
                right: '5%',
                bottom: '1%'
            },
            xAxis: {
                show:false,
                data: data.map(function (item,index) {
                    return item[0];
                })
            },
            yAxis: {
                show:false
            },
            series: {
                name: '转速',
                type: 'line',
                data: data.map(function (item) {
                    return item[1];
                }),
                lineStyle:{
                    color:"#06f788"
                }
            }
        }
        myChart.setOption(option);
        myChart.resize();
    }

    return (
        <div>
             <div id="main" style={{ width: '100%', height: 200 }}></div>
        </div>
    )
}
